package com.test.vue.service.impl;

import com.test.vue.entity.QueryPlaceEntity.*;
import com.test.vue.mapper.QueryPlaceMapper.SysAreasMapper;
import com.test.vue.mapper.QueryPlaceMapper.SysCitiesMapper;
import com.test.vue.mapper.QueryPlaceMapper.SysProvincesMapper;
import com.test.vue.service.QueryPlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class QueryPlaceServiceImpl implements QueryPlaceService{

    @Autowired
    SysProvincesMapper sysProvincesMapper;

    @Autowired
    SysCitiesMapper sysCitiesMapper;

    @Autowired
    SysAreasMapper sysAreasMapper;

    @Override
    public List<SysProvinces> queryProvince() {
        SysProvincesExample sysProvincesExample = new SysProvincesExample();
        SysProvincesExample.Criteria criteria = sysProvincesExample.createCriteria();
        List<SysProvinces> list = sysProvincesMapper.selectByExample(sysProvincesExample);
        System.out.println(list);
        return list;
    }
    //通过传来的省查询到市
    @Override
    public List<SysCities> queryCity(SysProvinces sysProvinces) {
        SysCitiesExample sysCitiesExample = new SysCitiesExample();
        SysCitiesExample.Criteria criteria = sysCitiesExample.createCriteria();
        criteria.andProvinceIdEqualTo(sysProvinces.getProvinceId() );
        List<SysCities> list = sysCitiesMapper.selectByExample(sysCitiesExample);
        System.out.println(list);
        return list;
    }

    //通过传来的城市查询地区
    @Override
    public List<SysAreas> queryArea(SysCities sysCities) {
        SysAreasExample sysAreasExample = new SysAreasExample();
        SysAreasExample.Criteria criteria = sysAreasExample.createCriteria();
        criteria.andCityIdEqualTo(sysCities.getCityId());
        List<SysAreas> list = sysAreasMapper.selectByExample(sysAreasExample);
        return list;
    }




}
